#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
using namespace std;
int Matrix[1007][1007];
struct node {
	int x,y;
	node (int a, int b) {
		x=a; y=b;
	}
	node () {}
	bool operator== (const node& a) const {
		return x==a.x && y==a.y;
	}
	bool operator!= (const node& a) const {
		return !(*(this)==a);
	}
	bool operator< (const node& a) const {
		if (x!=a.x) return x<a.x;
		else {
			return y<a.y;
		}
	}
	void operator= (const node& a) {
		x=a.x; y=a.y;
	}
};
set<node> res;
node Chaji[1007][1007];
void Cha(node a, node b) {
	node Top=a;
	while(Chaji[Top.x][Top.y]!=Top) {
		Top=Chaji[Top.x][Top.y];
	}
	Chaji[a.x][a.y]=Top;
	node Top2=b;
	while(Chaji[Top2.x][Top2.y]!=Top2) {
		node tmp=Top2;
		Top2=Chaji[Top2.x][Top2.y];
		Chaji[tmp.x][tmp.y]=Top;
	}
	Chaji[b.x][b.y]=Top;
	Chaji[Top2.x][Top2.y]=Top;
	if (res.count(Top2)) res.erase(Top2);
	res.insert(Top);
//	cout<<"Top2: "<<Top2.x<<","<<Top2.y<<endl;
}
struct Q {
	node st, en;
	Q(node a, node b) {
		st=a; en=b;
	}
	Q() {}
};
void Fuzhi(node st, node en) {
	if (st.x==en.x) {
		int &x=st.x;
		for (int i=st.y; i<=en.y; ++i) ++Matrix[x][i];
	}
	else {
		int &y=st.y;
		for (int i=st.x; i<=en.x; ++i) ++Matrix[i][y];
	}
} 
bool visited[1007][1007];
int n,m,q;
inline bool check(node a) {
	if (a.x<1 || a.x>n) return false;
	if (a.y<1 || a.y>m) return false;
	if (visited[a.x][a.y]) return false;
	if (Matrix[a.x][a.y]) return false;
	return true;
}
void BFS(node a) {
	queue<node> q;
	q.push(a);
	visited[a.x][a.y]=true;
	node pre,now;
	while (!q.empty()) {
		pre=q.front();
		q.pop();
		now.x=pre.x+1; now.y=pre.y;
		if (check(now)) {
			visited[now.x][now.y]=true;
			Chaji[now.x][now.y]=node(a.x, a.y);
			q.push(now);
		}
		now.x=pre.x-1; now.y=pre.y;
		if (check(now)) {
			visited[now.x][now.y]=true;
			Chaji[now.x][now.y]=node(a.x, a.y);
			q.push(now);
		}
		now.x=pre.x; now.y=pre.y+1;
		if (check(now)) {
			visited[now.x][now.y]=true;
			Chaji[now.x][now.y]=node(a.x, a.y);
			q.push(now);
		}
		now.x=pre.x; now.y=pre.y-1;
		if (check(now)) {
			visited[now.x][now.y]=true;
			Chaji[now.x][now.y]=node(a.x, a.y);
			q.push(now);
		}
	}
}
void MyBFS() {
	memset(visited, 0, sizeof(visited));
	res.clear();
	for (int i=1; i<=n; ++i) {
		for (int j=1; j<=m; ++j) {
			if (!visited[i][j] && !Matrix[i][j]) {
				res.insert(node(i,j));
				BFS(node(i,j));
			}
		}
	}
	memset(visited, 0, sizeof(visited));
}
void show() {
	cout<<"---------"<<endl;
	for (int i=1; i<=n; ++i) {
		for (int j=1; j<=m; ++j) {
			cout<<Matrix[i][j]<<" ";
		}
		cout<<endl;
	}
	for (set<node>::iterator it=res.begin(); it!=res.end(); ++it) {
		cout<<(*it).x<<","<<(*it).y<<endl;
	}
	cout<<"res: "<<res.size()<<endl;
	cout<<"--------"<<endl;
}
inline void Read(int &res) {
	char ch;
	ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	res=0;
	while (isdigit(ch)) res=res*10+ch-'0', ch=getchar();
} 
int main() {
	cin.sync_with_stdio(false);
	Read(n); Read(m); Read(q);
//	cin>>n>>m>>q;
	node st,en;
	stack<Q> AskQ;
	memset(Matrix, 0, sizeof(Matrix));
	for (int i=1; i<=n; ++i) {
		for (int j=1; j<=m; ++j) {
			Chaji[i][j]=node(i,j);
		}
	}
	for (int i=1; i<=q; ++i) {
		Read(st.x); Read(st.y); Read(en.x); Read(en.y);
//		cin>>st.x>>st.y>>en.x>>en.y;
		if (!(st<en)) swap(st,en);
		Fuzhi(st, en);
		AskQ.push(Q(st,en));
	}
	MyBFS();
	stack<int> ANS;
//	cout<<"res: "<<res.size()<<endl; 
//	show();
	for (int i=1; i<=q; ++i) {
		ANS.push(res.size());
		st=AskQ.top().st; en=AskQ.top().en;
		AskQ.pop();
		if (st.x==en.x) {
			int &x=st.x;
			for (int i=st.y; i<=en.y; ++i) {
				--Matrix[x][i];
				if (!Matrix[x][i]) {
					node near=node(x-1, i);
					node now=node(x, i);
					if (!res.count(now)) res.insert(now);
					if (check(near)) {
						Cha(now, near);
					}
					near=node(x+1, i);
					if (check(near)) {
						Cha(now, near);
					}
					near=node(x, i-1);
					if (check(near)) {
						Cha(now, near);
					}
					near=node(x, i+1);
					if (check(near)) {
						Cha(now, near);
					}
				}
			}
		}
		else {
			int &y=st.y;
			for (int i=st.x; i<=en.x; ++i) {
				--Matrix[i][y];
				if (!Matrix[i][y]) {
					node near=node(i, y-1);
					node now=node(i, y);
					if (!res.count(now)) res.insert(now);
					if (check(near)) {
						Cha(now, near);
					}
					near=node(i, y+1);
					if (check(near)) {
						Cha(now, near);
					}
					near=node(i+1, y);
					if (check(near)) {
						Cha(now, near);
					}
					near=node(i-1, y);
					if (check(near)) {
						Cha(now, near);
					}
				}
			}
		}
//		show();
		
	}
	for (int i=1; i<=q; ++i) {
		cout<<ANS.top()<<endl;
		ANS.pop();
	}
	return 0;
} 
